﻿using System;
namespace Producers.Karis.Xtee.Riik.Ee.Producer.Karis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="krIsikud_paring", Namespace="http://producers.karis.xtee.riik.ee/producer/karis", Target=typeof(KrIsikudParing))]
    public class KrIsikudParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKrIsikudParing clazz;
        
        public KrIsikudParingSerializer(IKrIsikudParing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("eesnimi");
            if (clazz.Eesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Eesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("perenimi");
            if (clazz.Perenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Perenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("synnikuupaev");
            if (clazz.Synnikuupaev!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Synnikuupaev))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Synnikuupaev");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "isikukood")) {
                goto isikukood;
            }
            else {
                if ((Reader.LocalName == "eesnimi")) {
                    goto eesnimi;
                }
                else {
                    if ((Reader.LocalName == "perenimi")) {
                        goto perenimi;
                    }
                    else {
                        if ((Reader.LocalName == "synnikuupaev")) {
                            goto synnikuupaev;
                        }
                        else {
                            return;
                        }
                    }
                }
            }
        isikukood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>krIsikud_paring>isikukood");
            }
            clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            goto START;
        eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>krIsikud_paring>eesnimi");
            }
            clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            goto START;
        perenimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>krIsikud_paring>perenimi");
            }
            clazz.Perenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("perenimi")).Value;
            goto START;
        synnikuupaev:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>krIsikud_paring>synnikuupaev");
            }
            clazz.Synnikuupaev = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synnikuupaev")).Value;
            goto START;
        }
    }
}
